package com.wwj.airline.Controller;

import com.wwj.airline.pojo.SeatType;
import com.wwj.airline.Dao.SeatTypeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/seattype")
public class SeatTypeHandler {
    @Autowired(required = false)
    private SeatTypeRepository seatTypeRepository;

    @GetMapping("/findAll")
    public List<SeatType> findAll(){
        return seatTypeRepository.findAll();
    }

    @GetMapping("/findById/{id}")
    public SeatType findById(@PathVariable("id") Long id){
        return seatTypeRepository.findById(id);
    }

    @PostMapping("/save")
    public void save(@RequestBody SeatType seatType){
        seatTypeRepository.save(seatType);
    }

    @PutMapping("/update")
    public void update(@RequestBody SeatType seatType){
        seatTypeRepository.update(seatType);
    }

    @DeleteMapping("/deleteById/{id}")
    public void deleteById(@PathVariable("id") Long id){
        seatTypeRepository.deleteById(id);
    }
}
